import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;

import 'app_localizations_en.dart';
import 'app_localizations_fr.dart';
import 'app_localizations_zh.dart';

// ignore_for_file: type=lint

/// Callers can lookup localized strings with an instance of AppLocalizations
/// returned by `AppLocalizations.of(context)`.
///
/// Applications need to include `AppLocalizations.delegate()` in their app's
/// `localizationDelegates` list, and the locales they support in the app's
/// `supportedLocales` list. For example:
///
/// ```dart
/// import 'l10n/app_localizations.dart';
///
/// return MaterialApp(
///   localizationsDelegates: AppLocalizations.localizationsDelegates,
///   supportedLocales: AppLocalizations.supportedLocales,
///   home: MyApplicationHome(),
/// );
/// ```
///
/// ## Update pubspec.yaml
///
/// Please make sure to update your pubspec.yaml to include the following
/// packages:
///
/// ```yaml
/// dependencies:
///   # Internationalization support.
///   flutter_localizations:
///     sdk: flutter
///   intl: any # Use the pinned version from flutter_localizations
///
///   # Rest of dependencies
/// ```
///
/// ## iOS Applications
///
/// iOS applications define key application metadata, including supported
/// locales, in an Info.plist file that is built into the application bundle.
/// To configure the locales supported by your app, you’ll need to edit this
/// file.
///
/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file.
/// Then, in the Project Navigator, open the Info.plist file under the Runner
/// project’s Runner folder.
///
/// Next, select the Information Property List item, select Add Item from the
/// Editor menu, then select Localizations from the pop-up menu.
///
/// Select and expand the newly-created Localizations item then, for each
/// locale your application supports, add a new item and select the locale
/// you wish to add from the pop-up menu in the Value field. This list should
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
  AppLocalizations(String locale)
    : localeName = intl.Intl.canonicalizedLocale(locale.toString());

  final String localeName;

  static AppLocalizations? of(BuildContext context) {
    return Localizations.of<AppLocalizations>(context, AppLocalizations);
  }

  static const LocalizationsDelegate<AppLocalizations> delegate =
      _AppLocalizationsDelegate();

  /// A list of this localizations delegate along with the default localizations
  /// delegates.
  ///
  /// Returns a list of localizations delegates containing this delegate along with
  /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
  /// and GlobalWidgetsLocalizations.delegate.
  ///
  /// Additional delegates can be added by appending to this list in
  /// MaterialApp. This list does not have to be used at all if a custom list
  /// of delegates is preferred or required.
  static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
      <LocalizationsDelegate<dynamic>>[
        delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ];

  /// A list of this localizations delegate's supported locales.
  static const List<Locale> supportedLocales = <Locale>[
    Locale('en'),
    Locale('fr'),
    Locale('zh'),
  ];

  /// No description provided for @appName.
  ///
  /// In en, this message translates to:
  /// **'Series app'**
  String get appName;

  /// No description provided for @tabHome.
  ///
  /// In en, this message translates to:
  /// **'Home'**
  String get tabHome;

  /// No description provided for @tabForYou.
  ///
  /// In en, this message translates to:
  /// **'For You'**
  String get tabForYou;

  /// No description provided for @tabPerks.
  ///
  /// In en, this message translates to:
  /// **'Perks'**
  String get tabPerks;

  /// No description provided for @tabBingeWatch.
  ///
  /// In en, this message translates to:
  /// **'Binge Watch'**
  String get tabBingeWatch;

  /// No description provided for @tabMe.
  ///
  /// In en, this message translates to:
  /// **'Me'**
  String get tabMe;

  /// No description provided for @splashWelcomeTip.
  ///
  /// In en, this message translates to:
  /// **'Massive Short Dramas, Waiting for You!'**
  String get splashWelcomeTip;

  /// No description provided for @search.
  ///
  /// In en, this message translates to:
  /// **'Search'**
  String get search;

  /// No description provided for @hotSearches.
  ///
  /// In en, this message translates to:
  /// **'Hot Searches'**
  String get hotSearches;

  /// No description provided for @hotVideos.
  ///
  /// In en, this message translates to:
  /// **'Hot Videos'**
  String get hotVideos;

  /// No description provided for @login.
  ///
  /// In en, this message translates to:
  /// **'Login'**
  String get login;

  /// No description provided for @wallet.
  ///
  /// In en, this message translates to:
  /// **'Wallet'**
  String get wallet;

  /// No description provided for @perks.
  ///
  /// In en, this message translates to:
  /// **'Perks'**
  String get perks;

  /// No description provided for @playHistory.
  ///
  /// In en, this message translates to:
  /// **'Play History'**
  String get playHistory;

  /// No description provided for @serverPeople.
  ///
  /// In en, this message translates to:
  /// **'Customer service'**
  String get serverPeople;

  /// No description provided for @language.
  ///
  /// In en, this message translates to:
  /// **'Language'**
  String get language;

  /// No description provided for @setting.
  ///
  /// In en, this message translates to:
  /// **'Setting'**
  String get setting;

  /// No description provided for @quickLoginIconName.
  ///
  /// In en, this message translates to:
  /// **'Short drama platform'**
  String get quickLoginIconName;

  /// No description provided for @facebookLogin.
  ///
  /// In en, this message translates to:
  /// **'Facebook login'**
  String get facebookLogin;

  /// No description provided for @googleLogin.
  ///
  /// In en, this message translates to:
  /// **'Google login'**
  String get googleLogin;

  /// No description provided for @appleLogin.
  ///
  /// In en, this message translates to:
  /// **'Apple login'**
  String get appleLogin;

  /// No description provided for @accountLogin.
  ///
  /// In en, this message translates to:
  /// **'Account login'**
  String get accountLogin;

  /// No description provided for @loginAgreementPrefix.
  ///
  /// In en, this message translates to:
  /// **'If you continue to log in, you agree to the'**
  String get loginAgreementPrefix;

  /// No description provided for @loginAgreementAnd.
  ///
  /// In en, this message translates to:
  /// **' and '**
  String get loginAgreementAnd;

  /// No description provided for @userAgreement.
  ///
  /// In en, this message translates to:
  /// **'User Agreement'**
  String get userAgreement;

  /// No description provided for @privacyAgreement.
  ///
  /// In en, this message translates to:
  /// **'Privacy Agreement'**
  String get privacyAgreement;

  /// No description provided for @messageNotify.
  ///
  /// In en, this message translates to:
  /// **'Message notification'**
  String get messageNotify;

  /// No description provided for @clearCache.
  ///
  /// In en, this message translates to:
  /// **'Clear cache'**
  String get clearCache;

  /// No description provided for @logout.
  ///
  /// In en, this message translates to:
  /// **'Logout'**
  String get logout;

  /// No description provided for @languageSelect.
  ///
  /// In en, this message translates to:
  /// **'Language Settings'**
  String get languageSelect;

  /// No description provided for @languageEnglish.
  ///
  /// In en, this message translates to:
  /// **'English'**
  String get languageEnglish;

  /// No description provided for @languageSimplifiedChinese.
  ///
  /// In en, this message translates to:
  /// **'Simplified Chinese'**
  String get languageSimplifiedChinese;

  /// No description provided for @languageTraditionalChinese.
  ///
  /// In en, this message translates to:
  /// **'Traditional Chinese'**
  String get languageTraditionalChinese;

  /// No description provided for @languageFrancais.
  ///
  /// In en, this message translates to:
  /// **'Francais'**
  String get languageFrancais;

  /// No description provided for @email.
  ///
  /// In en, this message translates to:
  /// **'Email'**
  String get email;

  /// No description provided for @password.
  ///
  /// In en, this message translates to:
  /// **'Password'**
  String get password;

  /// No description provided for @pleaseInputEmail.
  ///
  /// In en, this message translates to:
  /// **'Please enter email'**
  String get pleaseInputEmail;

  /// No description provided for @pleaseInputPassword.
  ///
  /// In en, this message translates to:
  /// **'Please enter password'**
  String get pleaseInputPassword;

  /// No description provided for @accountRegister.
  ///
  /// In en, this message translates to:
  /// **'Register account'**
  String get accountRegister;

  /// No description provided for @reEnterPassword.
  ///
  /// In en, this message translates to:
  /// **'Re-enter password'**
  String get reEnterPassword;

  /// No description provided for @pleaseInputPasswordAgain.
  ///
  /// In en, this message translates to:
  /// **'Please re-enter password'**
  String get pleaseInputPasswordAgain;

  /// No description provided for @verifyCode.
  ///
  /// In en, this message translates to:
  /// **'Verification code'**
  String get verifyCode;

  /// No description provided for @pleaseInputVerifyCode.
  ///
  /// In en, this message translates to:
  /// **'Please enter code'**
  String get pleaseInputVerifyCode;

  /// No description provided for @sendVerifyCode.
  ///
  /// In en, this message translates to:
  /// **'Send code'**
  String get sendVerifyCode;

  /// No description provided for @registerAndLogin.
  ///
  /// In en, this message translates to:
  /// **'Register / Login'**
  String get registerAndLogin;

  /// No description provided for @vipSubscribeRule.
  ///
  /// In en, this message translates to:
  /// **'会员订阅规则:\n1.在订阅期间，可以无限制的观看短剧平台上的所有剧集。\n2.每个订阅周期，你的订阅费用将自动从你选择的支付方式中扣除。\n3.除非你通过google play的订阅部分取消，否则你的订阅将以相同的价格自动续订。'**
  String get vipSubscribeRule;

  /// No description provided for @weekly.
  ///
  /// In en, this message translates to:
  /// **'Weekly Subscription'**
  String get weekly;

  /// No description provided for @monthly.
  ///
  /// In en, this message translates to:
  /// **'Monthly Subscription'**
  String get monthly;

  /// No description provided for @yearly.
  ///
  /// In en, this message translates to:
  /// **'yearly Subscription'**
  String get yearly;

  /// 用于订阅权益说明，{days} 为动态天数（如7/30/365）
  ///
  /// In en, this message translates to:
  /// **'Enjoy {days} days of unlimited viewing.'**
  String unlimitedViewingDesc(int days);

  /// No description provided for @day.
  ///
  /// In en, this message translates to:
  /// **'ay'**
  String get day;
}

class _AppLocalizationsDelegate
    extends LocalizationsDelegate<AppLocalizations> {
  const _AppLocalizationsDelegate();

  @override
  Future<AppLocalizations> load(Locale locale) {
    return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
  }

  @override
  bool isSupported(Locale locale) =>
      <String>['en', 'fr', 'zh'].contains(locale.languageCode);

  @override
  bool shouldReload(_AppLocalizationsDelegate old) => false;
}

AppLocalizations lookupAppLocalizations(Locale locale) {
  // Lookup logic when only language code is specified.
  switch (locale.languageCode) {
    case 'en':
      return AppLocalizationsEn();
    case 'fr':
      return AppLocalizationsFr();
    case 'zh':
      return AppLocalizationsZh();
  }

  throw FlutterError(
    'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
    'an issue with the localizations generation tool. Please file an issue '
    'on GitHub with a reproducible sample app and the gen-l10n configuration '
    'that was used.',
  );
}
